# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=tplmap
pkgver=719.616b0e5
pkgrel=3
pkgdesc='Automatic Server-Side Template Injection Detection and Exploitation Tool.'
groups=('blackarch' 'blackarch-webapp' 'blackarch-exploitation')
arch=('any')
url='https://github.com/epinna/tplmap'
license=('custom:unknown')
depends=('python2' 'python2-requests' 'python2-yaml' 'python2-flask'
         'python2-idna' 'python2-chardet' 'python2-certifi' 'python2-urllib3')
makedepends=('git')
source=("git+https://github.com/epinna/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

